<template>
	<view class="content">
		<!-- <view class="top" :style="{paddingTop: statusBarHeight + 'px'}">
			<text class="nickname">微信昵称</text>
		</view> -->
		<u-sticky offset-top="0">
			<u-navbar placeholder bgColor="#CE3026" :fixed="false">
				<view class="logo" slot="left">
					<img :src="baseUrl + configData.logo_image" alt=""
						style="width: 56rpx;height: 56rpx;margin-right: 8rpx;border-radius: 50%;" v-if="configData.logo_image">
					<text>{{configData.company || ''}}</text>
				</view>
				<view slot="title"></view>
			</u-navbar>
		</u-sticky>
		
		<!-- 顶部轮播图 -->
		<view class="swiper">
			<img :src="baseUrl + configData.top_image" alt="" srcset="" mode="widthFix" v-if="configData.top_image">
		</view>


		<!-- 服务内容 -->
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="toProduct(item)">
				<img :src="baseUrl + item.image" alt="" mode="widthFix">
				<view class="item_title">
					{{item.name}}
				</view>
			</view>
		</view>
		
		<view v-for="(item,index) in list" :key="item.id">
			<view class="card">
				<u-cell value="更多" :border="false" >
					<view slot="title" class="card_title" > {{item.name}} </view>
					<view slot="value" class="card_more" @click="toProduct(item)" >
						更多 <u-icon name="arrow-right" style="margin-left:10rpx;"></u-icon>
					</view>
				</u-cell>
				<view class="card_info"  v-if="item.id ==2 || item.id == 5">
					<view class="card_info_item" v-for="itm in item.list" :key="itm.id" @click="toDetail(itm,item)">
						<view class="card_info_item_img">
							<img :src="baseUrl + itm.image" alt="" mode="widthFix">
						</view>
						<view class="card_info_item_text u-line-1">
							{{itm.name}}
						</view>
					</view>
				</view>
				<view class="card_info1"  v-if="item.id ==3">
					<view class="" v-for="itm in item.list" :key="itm.id" @click="toDetail(itm,item)">
						<view class="card_info1_img" >
							<img :src="baseUrl + itm.image" alt="" mode="widthFix">
						</view>
						<view class="card_info1_title">
							{{itm.name}}
						</view>
						<view class="card_info1_subtitle u-line-1">
							{{itm.subtitle}}
						</view>
					</view>
				</view>
				<view class="" v-if="item.id ==4 || item.id == 6">
					<view class="card_info2" v-for="itm in item.list" :key="itm.id" @click="toDetail(itm,item)">
						<view class="card_info2_img">
							<img :src="baseUrl + itm.image" alt="" mode="widthFix">
						</view>
						<view class="right">
							<view class="card_info2_title">
								{{itm.name}}
							</view>
							<view class="card_info2_subtitle u-line-2">
								{{itm.subtitle}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="company">
			<view class="company_img">
				<img :src="baseUrl + configData.main" alt="" mode="widthFix" v-if="configData.main">
			</view>
			<view class="company_name">
				<img src="/static/images/logo1.png" alt=""  mode="widthFix" style="width: 50rpx;margin-right: 8rpx;">
				<text>{{configData.company || ''}}</text>
			</view>
			<view class="company_phone">
				<img src="/static/images/phone.png" alt=""  mode="widthFix" style="width: 32rpx;margin-right: 4rpx;">
				<rich-text :nodes="configData.phone" class="rich_val"></rich-text>
			</view>
			<view class="company_desc u-line-2">
				<rich-text :nodes="configData.about_us" class="rich_val" ></rich-text>
				<!-- <view class="company_desc_more">
					<text>...</text> <text class="company_desc_more_more">查看更多〉</text>
				</view> -->
			</view>
		</view>

		<view class="kefu" @click="toConcatUs">
			<img src="/static/images/kefu.png" alt="" srcset="" mode="widthFix">
		</view>

		<view class="bottom">
			我已经到底了~
		</view>

		<!-- 底部tabber -->
		<m-tabbar fixed fill current="0" :tabbar="tabbar">
			<template v-slot:tabbar_index_1>
				<button open-type="contact" class="custom_btn">
					<view class="custom_style">
						<view class="custom_style_img">
							<img src="/static/images/tabbar/tabbar_kefu.png" alt="">
						</view>
						<view class="custom_style_text">
							联系客服
						</view>
					</view>
				</button>
			</template>
		</m-tabbar>
	</view>
</template>

<script>
	import TabbarConfig from '@/config/tabbar.js'
	import {
		baseUrl
	} from '@/api/request.js'
	import {
		main,config
	} from '@/api/api.js'

	export default {
		data() {
			return {
				tabbar: TabbarConfig,
				//状态栏的高度
				statusBarHeight: 0,
				list: [],
				configData:{},
				baseUrl
			}
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res) => {
					let {
						statusBarHeight
					} = res;
					this.statusBarHeight = statusBarHeight;
				}
			})
			this.getData()
			this.getConfig()
		},
		methods: {
			getData() {
				main().then(res => {
					console.log(res);
					this.list = res.data
				})
			},
			getConfig(){
				config().then(res=>{
					this.configData = res.data
				})
			},
			toProduct(item){
				uni.navigateTo({
					url:`/pages/product/product?id=${item.id}&name=${item.name}`
				})
			},
			toDetail(itm,item){
				if(itm.enum == '产品'){
					uni.navigateTo({
						url:'/pages/product/question?id=' + itm.id
					})
				}else  {
					uni.navigateTo({
						url:`/pages/product/detail?id=${itm.id}&pId=${item.id}`
					})
				}
			},
			toConcatUs(){
				uni.navigateTo({
					url:'/pages/index/concatUs'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: 78rpx;
		view {
			box-sizing: border-box;
		}
	}

	.logo {
		font-size: 36rpx;
		font-family: PingFang SC-Semibold, PingFang SC;
		font-weight: 600;
		color: #FFFFFF;
		line-height: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.swiper {
		background: linear-gradient(180deg, #CE3026 0rpx, #F8F8F8 50%, #F8F8F8 100%);
		padding: 0 32rpx;
		img {
			width: 100%;
			border-radius: 16rpx;
		}
	}

	.list {
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		margin-top: 32rpx;

		img {
			width: 96rpx;
			height: 96rpx;
		}

		.item {
			&_title {
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
				line-height: 28rpx;
				text-align: center;
			}
		}
	}
	
	.card {
		background-color: #fff;
		border-radius: 10rpx 10rpx 0 0;
		padding: 30rpx 36rpx;
		padding-top: 15rpx;
		margin-top: 20rpx;
		/deep/ .u-cell__body {
			padding-left: 0 !important;
			padding-right: 0 !important;
		}
		&_title {
			font-size: 32rpx;
			font-family: PingFang SC-Semibold, PingFang SC;
			font-weight: 600;
			color: #333333;
			padding-left: 8rpx;
			border-left: 8rpx solid #CE3026;
		}
		&_more {
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			display: flex;
		}
		&_info {
			display: flex;
			column-gap: 22rpx;
			align-items: center;
			width: 100%;
			&_item {
				flex: 1;
				max-width: calc(33.33% - 15rpx);
				display: flex;
				flex-direction: column;
				align-items: center;
				&_img {
					width: 100%;
					overflow: hidden;
					border-radius: 8rpx;
					img {
						width: 100%;
					}
				}
				&_text {
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}
			}
		}
		&_info1 {
			&_img {
				width: 100%;
				img {
					width: 100%;
				}
			}
			&_title {
				margin-top: 16rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Semibold, PingFang SC;
				font-weight: 600;
				color: #333333;
				line-height: 33rpx;
			}
			&_subtitle {
				margin-top: 8rpx;
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 28rpx;
			}
		}
		&_info2 {
			display: flex;
			margin-bottom: 20rpx;
			&_img {
				width: 184rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-right: 16rpx;
				img {
					width: 184rpx;
				}
			}
			&_title {
				font-size: 28rpx;
				font-family: PingFang SC-Semibold, PingFang SC;
				font-weight: 600;
				color: #333333;
				line-height: 33rpx;
			}
			&_subtitle {
				margin-top: 10rpx;
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 40rpx;
			}
		}
	}

	.company {
		background-color: #fff;
		padding-bottom: 60rpx;
		&_img {
			width: 100vw;
			img {
				width: 100%;
			}
		}
		&_name {
			padding: 16rpx 0;
			padding-left: 32rpx;
			display: flex;
			align-items: center;
			font-size: 36rpx;
			font-family: PingFang SC-Semibold, PingFang SC;
			font-weight: 600;
			color: #003A8E;
			line-height: 48rpx;
		}
		&_phone {
			padding-left: 32rpx;
			display: flex;
			align-items: center;
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			line-height: 48rpx;
		}
		&_desc {
			padding: 0 32rpx;
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
			position: relative;
			&_more {
				position: absolute;
				right: 32rpx;
				bottom: 0;
				background-color: #fff;
				width: 140rpx;
				&_more {
					color: #418BFF;
				}
			}
		}
	}
	.kefu {
		position: fixed;
		bottom: 300rpx;
		right: 36rpx;
		width: 92rpx;
		img{
			width: 92rpx;
		}
	}
	.bottom {
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 40rpx;
		margin-top: 90rpx;
		text-align: center;
	}
</style>
